package com.merelyb.data.service.service.service.token;

import com.merelyb.data.service.common.MultiDataSourceContextHolder;
import com.merelyb.data.service.service.mybatis.bean.token.TokenInfo;
import com.merelyb.data.service.service.mybatis.dao.token.TokenInfoDao;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * Created by LiM on 2017/12/12.
 */
@Service
public class TokenInfoService {
    @Autowired
    TokenInfoDao tokenInfoDao;

    /**
     * 查询数据
     * @param tokenInfo
     * @return
     * @throws Exception
     */
    public List<TokenInfo> queryAllList(TokenInfo tokenInfo) throws Exception{
        return tokenInfoDao.queryAllList(tokenInfo, MultiDataSourceContextHolder.DATA_TOKEN);
    }

    /**
     * 分页查询数据
     * @param tokenInfo
     * @return
     */
    public List<TokenInfo> queryListByLimit(TokenInfo tokenInfo){
        return tokenInfoDao.queryListByLimit(tokenInfo, MultiDataSourceContextHolder.DATA_TOKEN);
    }

    /**
     * 新增单条数据
     * @param tokenInfo
     * @throws Exception
     */
    public void addData(TokenInfo tokenInfo) throws Exception{
        tokenInfoDao.addData(tokenInfo, MultiDataSourceContextHolder.DATA_TOKEN);
    }

    /**
     * 批量新增数据
     * @param tokenInfoList
     * @throws Exception
     */
    public void addData(List<TokenInfo> tokenInfoList) throws Exception {
        tokenInfoDao.addData(tokenInfoList, MultiDataSourceContextHolder.DATA_TOKEN);
    }

    /**
     * 更新数据
     * @param tokenInfo
     * @throws Exception
     */
    public void updateData(TokenInfo tokenInfo) throws Exception{
        tokenInfoDao.updateData(tokenInfo, MultiDataSourceContextHolder.DATA_TOKEN);
    }

    /**
     * 更新数据状态
     * @param tokenInfo
     * @throws Exception
     */
    public void deleteData(TokenInfo tokenInfo) throws Exception{
        tokenInfoDao.deleteData(tokenInfo, MultiDataSourceContextHolder.DATA_TOKEN);
    }

    /**
     * 统计数量
     * @param tokenInfo
     * @return
     */
    public int getCount(TokenInfo tokenInfo){
        return tokenInfoDao.getCount(tokenInfo, MultiDataSourceContextHolder.DATA_TOKEN);
    }
}
